import { masksPoint } from '@/config';

export function addMasks(map: any) {
  const TMap = (window as any).TMap;
  if (!TMap) throw new Error('TMap 未注入');

  const geometries = masksPoint.map((m) => ({ id: m.id, paths: m.paths.map((p) => new TMap.LatLng(...p)) }));
  const instance = new TMap.MaskLayer({ map, geometries });
  instance.on('click', (evt: any) => console.log('遮罩层点击事件：', evt.geometry.id));
  return instance;
}

export default { addMasks };
